/**
 * 
 */
package name.shamansir.tadah.data;

/**
 * <dl>
 * <dt>Project:</dt> <dd>ta-dah</dd>
 * <dt>Package:</dt> <dd>name.shamansir.tadah.data</dd>
 * </dl>
 *
 * <code>HasId</code>
 *
 * <p>Description</p>
 *
 * @author Ulric Wilfred <shaman.sir@gmail.com>
 * @date Feb 21, 2011 10:41:37 PM 
 *
 */
public abstract class WithId {
    
    protected final int id;
    
    protected WithId(int id) { this.id = id; }
    
    public int getId() { return id; };
    
    public boolean isNew() { return id == -1; }
    
    @Override
    public boolean equals(Object other) {
        if (other == null) return false;
        if (other instanceof WithId) return (id == ((WithId)other).id);
        return false;
    };
    
    @Override
    public int hashCode() { return id; };
    
}
